<%@ page language="java" import="up7.*" pageEncoding="UTF-8"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@	page import="com.google.gson.Gson" %>
<%@ page import="up7.model.*" %>
<%@ page import="up7.biz.*" %>
<%@ page import="up7.utils.*" %>
<%@ page import="up7.database.*" %>
<%@ page import="up7.database.sql.SqlFile" %>
<%@	page import="org.apache.commons.lang.StringUtils" %>
<%@ page import="java.net.URLDecoder" %>
<%@ page import="java.net.URLEncoder" %>
<%@ page import="net.sf.json.JSONObject" %>
<%@ page import="up7.sql.SqlWhereMerge" %>
<%@ page import="up7.sql.SqlExec" %>
<%@ page import="net.sf.json.JSONArray" %>
<%@ page import="filemgr.PageFileMgr" %>
<%@ page import="up7.sql.SqlParam" %>
<%
    out.clear();

    WebBase web = new WebBase(pageContext);

    String name = web.reqStrDecode("nameLoc");
    String pid = web.reqStr("pid");
    String uid = web.reqStr("uid");
    String pidRoot = web.reqStr("pidRoot");
    String pathRel = web.reqStrDecode("pathRel");
    boolean isRootDir = StringUtils.equals(pathRel,"/");
    pathRel = PathTool.combine(pathRel, name);

    DbFolder df = DbFolder.build();
    if (df.exist_same_folder(pathRel))
    {
        JSONObject ret = new JSONObject();
        ret.put("ret", false);
        ret.put("msg", "已存在同名目录");
        out.write(ret.toString());
        return;
    }

    FileInf dir = new FileInf();
    dir.id = PathTool.guid();
    dir.pid = pid;
    dir.uid = uid;
    dir.pidRoot = pidRoot;
    dir.nameLoc = name;
    dir.nameSvr = name;
    dir.complete = true;
    dir.fdTask = true;
    dir.pathRel = pathRel;

    //根目录
    if ( isRootDir )
    {
    	SqlFile.build().Add(dir);
    }//子目录
    else
    {
    	DbFolder.build().add(dir);
    }

    JSONObject ret = JSONObject.fromObject(dir);
    ret.put("ret", true);
    out.write(ret.toString());
%>